package com.lxw.ObserverPaterns.Display;

import com.lxw.ObserverPaterns.Observer.Observer;
import com.lxw.ObserverPaterns.Subject.Subject;

public class CurrentCoditionsDisplay implements Observer,DisplayElement {
    private double temperature;
    private double humidity;
    private double pressure;
    private Subject weatherData;


    public CurrentCoditionsDisplay(Subject weatherData){
        this.weatherData=weatherData;
        weatherData.registerObserver(this);
    }


    public void display() {
        System.out.println("当前天气状态 温度："+temperature+" 湿度:"+humidity+" 压力:"+pressure );
    }

    public void update(double temp, double humidity, double pressure) {
        this.temperature=temp;
        this.humidity=humidity;
        this.pressure=pressure;
        display();
    }
}
